import { defHttp } from '/@/utils/http/axios'

enum Api {
  All = '/sysPermission/all',
  ListByRole = '/sysPermission/listByRole',
  Page = '/sysPermission/page',
  Add = '/sysPermission/add',
}

export const all = () => {
  return defHttp.get<any>({ url: Api.All }, { urlPrefix: '/user' })
}

export const listByRole = (roleId: string) => {
  return defHttp.get<any>({ url: Api.ListByRole, params: { roleId } }, { urlPrefix: '/user' })
}

export const page = (param: any) => {
  return defHttp.get<any>({ url: Api.Page, params: param }, { urlPrefix: '/user' })
}

export const add = (param: any) => {
  return defHttp.post<any>(
    { url: Api.Add, params: param },
    { urlPrefix: '/user', errorMessageMode: 'modal', successMessage: 'message' },
  )
}
